import { useIntervalFn } from '@vueuse/core'

import { ref } from 'vue'
export const useCountDown = (init = 60) => {
  const count = ref(init)
  const { pause, resume } = useIntervalFn(() => {
    count.value--
    if (count.value <= 0) {
      pause()
    }
  }, 1000)
  const start = () => {
    count.value = init
    resume()
  }
  return {
    count,
    start
  }
}
